/**
 * 
 */
package com.gmail.blackdog1987.onedollar.web.controller;

import com.gmail.blackdog1987.onedollar.service.SmsService;
import com.gmail.blackdog1987.onedollar.service.SystemService;
import com.gmail.blackdog1987.onedollar.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 
 * @author 董国超
 *
 */
@Controller
public class SystemController extends BaseController {
	@Autowired
	private SystemService systemService;

	/**
	 * 获取广告列表
	 * @param filter
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="getAds", method=RequestMethod.POST)
	public Map<String, Object> login(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = systemService.getAds(filter);
		return decorateResult(result);
	}

	/**
	 * 获取公告列表
	 * @param filter
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="getNotice", method=RequestMethod.POST)
	public Map<String, Object> getuser(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = systemService.getNotice(filter);
		return decorateResult(result);
	}

	/**
	 * 获取声明
	 * @param filter
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="getPrivacy", method=RequestMethod.POST)
	public Map<String, Object> getPrivacy(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = systemService.getPrivacy(filter);
		return decorateResult(result);
	}

	/**
	 * 阅读通知
	 * @param filter
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="readNotice", method=RequestMethod.POST)
	public Map<String, Object> readNotice(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = systemService.doReadNotice(filter);
		return decorateResult(result);
	}

	@Override
	protected Map<String, Object> decorateResult(Map<String, Object> result) {
		result.put("time", System.currentTimeMillis());
		return result;
	}
}
